/**
 * 
 */
package lt.vin.exaatto.client.ui;

import java.util.Arrays;

import com.google.gwt.user.client.ui.Widget;

import lt.vin.exaatto.client.events.ChatRemovedHandler;
import lt.vin.exaatto.client.events.ChatSelectedHandler;
import lt.vin.exaatto.shared.Chat;


/**
 * @author Vincentas
 *
 */
public class OwnerPanel extends BaseContainerWidget<String> implements ChatSelectedHandler, ChatRemovedHandler {

	public OwnerPanel() {
		super("Owner");
		
		setShowAddButton(false);
		
		Stat.getHandlerManager().addHandler(ChatSelectedHandler.type, this);
		Stat.getHandlerManager().addHandler(ChatRemovedHandler.type, this);
	}

	@Override
	public void selectedChat(Chat chat) {
		setElements(Arrays.asList(new String[]{chat.getOwner()}));
		setVisible(true);
		
	}

	@Override
	public void removedChat(Chat chat) {
		clear();
		setVisible(false);
	}

	@Override
	protected void newTextEntered(String text) {
		// do nothing
	}

	/* (non-Javadoc)
	 * @see lt.vin.exaatto.client.ui.BaseContainerWidget#createElementWidget(java.lang.Object)
	 */
	@Override
	protected ElementWidget<String> createElementWidget(String element) {
		ElementWidget<String> elementWidget = super.createElementWidget(element);
		
		elementWidget.setRemovable(false);
		
		return elementWidget;
	}
	
	
}
